<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="./js/vue.js"></script>
<body>
    <div class="box">
        <h1>{{msg}}</h1>
        <!--  组件可以复用-->
        <yang-yang></yang-yang>
        <yang-yang></yang-yang>
        <yang-yang></yang-yang>
        <yang-yang></yang-yang>
        <yang-yang></yang-yang>
        <zi-hao></zi-hao>
    </div>
    <div class="box2">
        <!-- <yang-yang></yang-yang> -->
        <zi-hao></zi-hao>
    </div>
    <script>
        // 定义全局的组件
        Vue.component('zi-hao',{
            data(){
                return {
                    msg:'七日核算必检',
                }
            },
            methods: {
                test(){
                    console.log('test')
                }
            },
            template:'<p><span>{{msg}}</span><button @click="test">测试事件绑定</button></p>'
        })
        // 组件component
        let YangYang = {
            data(){
                return {
                    num:0
                }
            },
            template:'<h1>{{num}}</h1>'
        }
        const vm = new Vue({
            el:'.box',
            data:{
                msg:'yangyangyangyang'
            },
            // 每个实例可以维护一份被返回的对象
            // 局部组件
            components:{
                'yang-yang':YangYang
            }
        })
        const vm2 = new Vue({
            el:'.box2'
        })

        /* 
        组件当中data是函数不能像vue实例当中写成一个对象，
        */
    </script>
</body>
</html>